const { goodsFormatError} = require('@/constant/errType')

const validator = async (ctx, next) => {
  try {
    ctx.verifyParams({
      name:{type: 'string', required: true}
    })
  } catch (err) {
    goodsFormatError.result = err
    return ctx.app.emit('error', goodsFormatError, ctx)
  }
  
  await next()
}

const validatorClass = async (ctx, next) => {
  try {
    ctx.verifyParams({
      name:{type: 'string', required: true},
      sdept_id:{type: 'string', required: true}
    })
  } catch(err) {
    goodsFormatError.result = err
    return ctx.app.emit('error', goodsFormatError, ctx)
  }
  await next()
}



module.exports = {
  validator,
  validatorClass
}